package config;

import org.json.simple.JSONObject;

import util.KIntChange;
import util.KJsonObject;
import util.KPrintInfo;

public class MapConfig {
	static private MapConfig	config	= new MapConfig();
	private JSONObject			jsonObject;
	
	private int					enter;
	
	private int					walk;
	
	static public MapConfig getInstance() {
		return config;
	}
	
	public void init() {
		if (loadConfing()) {
			KPrintInfo.println("Map----config----加载配置文件成功");
		} else {
			KPrintInfo.println("Map----config----加载配置文件失败");
		}
	}
	
	/**
	 * 加载配置文件
	 * 
	 * @return
	 */
	public Boolean loadConfing() {
		LoadFile loadFile = new LoadFile();
		
		String fileString = loadFile.Load("config/map/MapConfig");
		jsonObject = KJsonObject.decode(fileString);
		
		return initConfigData();
	}
	
	private Boolean initConfigData() {
		enter = KIntChange.intChange(jsonObject.get("enter"));
		walk = KIntChange.intChange(jsonObject.get("walk"));
		
		return true;
	}
	
	public int getEnter() {
		return enter;
	}
	
	public int getWalk() {
		return walk;
	}
	
}
